using System;
namespace Servlets.Api
{
	/// <summary>
	/// Enum of the different Http Status codes.
	/// This class is provided to help ensure type-safty, however, a code maybe added in the future or simply not represented in this class. If that's the case then the constructor can be used to create any Http Status.
	/// Last updated August 28, 2010
	/// </summary>
	public class HttpStatus
	{
		public static HttpStatus STATUS_100_CONTINUE = new HttpStatus(200, "Continue");
		public static HttpStatus STATUS_101_SWITCHING_PROTOCOLS = new HttpStatus(200, "Swiching Protocol");
		
		public static HttpStatus STATUS_200_OK = new HttpStatus(200, "OK");
		public static HttpStatus STATUS_201_CREATED = new HttpStatus(201, "Created");
		public static HttpStatus STATUS_202_ACCEPTED = new HttpStatus(202, "Accepted");
		public static HttpStatus STATUS_203_NON_AUTHORITATIVE_INFORMATION = new HttpStatus(203, "Non-Authoritative Information");
		public static HttpStatus STATUS_204_NO_CONTENT = new HttpStatus(204, "No Content");
		public static HttpStatus STATUS_205_RESET_CONTENT = new HttpStatus(205, "Reset Content");
		public static HttpStatus STATUS_206_PARTIAL_CONTENT = new HttpStatus(206, "Partial Content");
		
		public static HttpStatus STATUS_300_MULTIPLE_CHOICES = new HttpStatus(300, "Multiple Choices");
		public static HttpStatus STATUS_301_MOVED_PERMANENTLY = new HttpStatus(301, "Moved Permanently");
		public static HttpStatus STATUS_302_FOUND = new HttpStatus(302, "Found");
		public static HttpStatus STATUS_303_SEE_OTHER = new HttpStatus(303, "See Other");
		public static HttpStatus STATUS_304_NOT_MODIFIED = new HttpStatus(304, "Not Modified");
		public static HttpStatus STATUS_305_USE_PROXY = new HttpStatus(305, "Use Proxy");
		public static HttpStatus STATUS_306_ = new HttpStatus(306, "OK");
		public static HttpStatus STATUS_307_TEMPORARY_REDIRECT = new HttpStatus(307, "OK");
		
		public static HttpStatus STATUS_400_BAD_REQUEST = new HttpStatus(400, "Bad Request");
		public static HttpStatus STATUS_401_UNAUTHORIZED = new HttpStatus(401, "Unauthorized");
		public static HttpStatus STATUS_402_PAYMENT_REQUIRED = new HttpStatus(402, "Payment Required");
		public static HttpStatus STATUS_403_FORBIDDEN = new HttpStatus(403, "Forbidden");
		public static HttpStatus STATUS_404_NOT_FOUND = new HttpStatus(404, "Not Found");
		public static HttpStatus STATUS_405_METHOD_NOT_ALLOWED = new HttpStatus(405, "Method Not Allowed");
		public static HttpStatus STATUS_406_NOT_ACCEPTABLE = new HttpStatus(406, "Not Acceptable");
		public static HttpStatus STATUS_407_PROXY_AUTHENTICATION_REQUIRED = new HttpStatus(407, "Proxy Authentication Required");
		public static HttpStatus STATUS_408_REQUEST_TIMEOUT = new HttpStatus(408, "Request Timeout");
		public static HttpStatus STATUS_409_CONFLICT = new HttpStatus(409, "Conflict");
		public static HttpStatus STATUS_410_GONE = new HttpStatus(410, "Gone");
		public static HttpStatus STATUS_411_LENGTH_REQUIRED = new HttpStatus(411, "Length Required");
		public static HttpStatus STATUS_412_PRECONDITION_FAILED = new HttpStatus(412, "Precondition Failed");
		public static HttpStatus STATUS_413_REQUEST_ENTITY_TOO_LARGE = new HttpStatus(413, "Request Entity Too Large");
		public static HttpStatus STATUS_414_REQUEST_URL_TOO_LONG = new HttpStatus(414, "Request-URI Too Long");
		public static HttpStatus STATUS_415_UNSUPPORTED_MEDIA_TYPE = new HttpStatus(415, "Unsupported Media Type");
		public static HttpStatus STATUS_416_REQUESTED_RANGE_NOT_SATISFIABLE = new HttpStatus(416, "Requested Range Not Satisfiable");
		public static HttpStatus STATUS_417_EXPECTATION_FAILED = new HttpStatus(417, "Expectation Failed");
		public static HttpStatus STATUS_418_IM_A_TEAPOT = new HttpStatus(418, "I'm a teapot");
		
		public static HttpStatus STATUS_500_INTERNAL_SERVER_ERROR = new HttpStatus(500, "Internal Server Error");
		public static HttpStatus STATUS_501_NOT_IMPLEMENTED = new HttpStatus(501, "Not Implemented");
		public static HttpStatus STATUS_502_BAD_GATEWAY = new HttpStatus(502, "Bad Gateway");
		public static HttpStatus STATUS_503_SERVICE_UNAVAILABLE = new HttpStatus(503, "Service Unavailable");
		public static HttpStatus STATUS_504_GATEWAY_TIMEOUT = new HttpStatus(504, "Gateway Timeout");
		public static HttpStatus STATUS_505_HTTP_VERSION_NOT_SUPPORTED = new HttpStatus(505, "HTTP Version Not Supported");
		
		public int Code{get;private set;}
		public string Status{get;private set;}
		
		/// <summary>
		/// This should only be used if there is no static constant defined already.
		/// </summary>
		/// <param name="code">
		/// A <see cref="System.Int32"/>
		/// </param>
		/// <param name="status">
		/// A <see cref="System.String"/>
		/// </param>
		public HttpStatus(int code, string status)
		{
			this.Code = code;
			this.Status = status;
		}
		
		public override bool Equals (object obj)
		{
			HttpStatus status = obj as HttpStatus;
			if(status == null) return false;
			return status.Code == this.Code;
		}
		
		public override int GetHashCode ()
		{
			return this.Code;
		}
		
		public override string ToString()
		{
			return string.Format("{0} {1}", Code, Status);
		}
	}
}

